<%--
  Created by IntelliJ IDEA.
  User: 22179
  Date: 2025/3/27
  Time: 16:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <script src="/static/css/jquery-3.3.1.js"></script>
    <title>Title</title>
    <style>
        table{
            border: 1px solid black;
            width: 800px;
            border-collapse: collapse;
            cellpadding:"0px" ;
            cellspacing:"0px";
        }
        table td, table th { /* 给所有的td和th加上边框 */
            border: 1px solid black;
            padding: 5px; /* 可以根据需要调整 */
        }
    </style>
    <script>
        var msg="${msg}";
        if(msg!=null && msg!=""){
            alert(msg);
        }


    </script>
</head>
<body>

<h1>欢迎${name}登录系统!</h1>
<button onclick="viewjbook()">查看借书记录</button>
<table>
    <tr>
        <td>编号</td>
        <td>书名</td>
        <td>作者</td>
        <td>数量</td>
        <td>操作</td>
    </tr>
    <c:forEach var="book" items="${list}">
        <tr>
            <td>${book.id}</td>
            <td>${book.name}</td>
            <td>${book.author}</td>
            <td>${book.bsum}</td>
            <td>
                <button onclick="addjbook(${book.id},${book.bsum})">借书</button>
            </td>
        </tr>
    </c:forEach>

</table>
<script>
    function viewjbook() {
        location.href="/Book?method=viewjbook";
    }
    function addjbook(bid, bsum) {
        if (bsum > 0){
            location.href="/Book?method=addjbook&bid="+bid;
        }else{
            alert("图书不足，无法借出");
        }

    }
</script>
</body>
</html>